﻿@*@page "/XSCKDPage"
@inject CKDServer cKDServer
@using System.ComponentModel
@using AntDesign.TableModels
@inject ModalService _modalService
@inject MessageService _message
<h3>暂存销售出库单列表</h3>
<div>
    <DatePicker @bind-Value="@dateTime" Picker="@DatePickerType.Date" style="width:100%" />
    <br />
    <Row>
        <Col Span="24">
        <Button style="width:100%" Type="@ButtonType.Primary" @onclick="@Scerh">查询暂存销售出库单</Button>
        <br>
        </Col>
    </Row>
    @if (XSCKDS.Count != 0)
    {
        foreach (var item in XSCKDS)
        {
            <Card Bordered="true" Title=@(item.FBILLNO)>
                <Body>
                    <p>客户：@(item.FCustomerName)</p>
                    <p>明细ID：@(item.FEntityID)</p>
                    <p>批号</p>
                    <Input @bind-Value=@(item.Flot)/>
                    <p>实发数量</p>
                    <Input type="number" @bind-Value=@(item.F) />
                    <Button style="width:100%" Type="@ButtonType.Primary" @onclick="@(async e=>{
                   await Creat(item.FBILLNO,item.FLOT, Convert.ToSingle( item.FRealQty));
                    })">
                        保存出库单
                    </Button>
                    <br>
                    <br>
                    <Button style="width:100%" Type="@ButtonType.Primary" @onclick="@(async e=>{
                   await Delete(item.FBILLNO);
                    })">
                        删除该暂存单
                    </Button>
                </Body>
            </Card>
            <br>
        }

    }
</div>

@code {
    DateTime dateTime = DateTime.Now.Date;
    string Batch { get; set; }
    List<XSCKD> XSCKDS = new List<XSCKD>();
    protected override async Task OnInitializedAsync()
    {
        var lists = await cKDServer.GetXSCKDS();
        XSCKDS.Clear();
        XSCKDS.AddRange(lists);
        base.OnInitialized();
    }
    private async Task init()
    {

        var lists = await cKDServer.GetXSCKDS();
        XSCKDS.Clear();
        XSCKDS.AddRange(lists);
        this.StateHasChanged();
    }

    private async Task Scerh()
    {

        await cKDServer.GetXSCKDS();
        await init();
        _message.Info("OK");
    }
    private async Task Creat(string FID, string FLOT, float FRealQty)
    {
        _modalService.Confirm(new ConfirmOptions()
            {
                Title = "提示",
                Icon =@<Icon Type="exclamation-circle" Theme="Outline"></Icon>,
            OkText = "确认",
            OnOk = async (e) =>
            {
                var aa = await cKDServer.SaveXSCKDS(FID,FLOT,FRealQty);
                _message.Info(aa);
                await init();
   
            },
            CancelText = "取消",
            Content = "是否提交？",
        });
    }

    private async Task Delete(string FID)
    {
        _modalService.Confirm(new ConfirmOptions()
            {
                Title = "提示",
                Icon =@<Icon Type="exclamation-circle" Theme="Outline"></Icon>,
            OkText = "确认",
            OnOk = async (e) =>
            {
                var aa = await cKDServer.DeletXSCKD(FID);
                _message.Info(aa);
                await init();

            },
            CancelText = "取消",
            Content = "是否提交？",
        });
    }
}
*@